<?php
$T->loadTpl("./html/".$template."/".$qname.".html");
$T->SetTpl('cssjs','html/cssjs.inc'); 
$T->SetTpl('jsmodel','html/jsmodel.inc');     

$p=isset($_GET["p"])?$_GET["p"]:"1";
$offset = ($p-1)*15;
if($offset<0) $offset = 0;
$type=isset($_GET['type'])?$_GET['type']:"send";
$uid=$_SESSION['uid'];
$str_html='';
if($type=='send'){
    $where = "and A.sender='".$uid."'";
    $list = $T->db->query("select A.*,B.truename from sys_notice A left join sys_member B on B.id=A.sender where 1=1 ".$where." order by A.id desc limit {$offset},15")->fetchAll(PDO::FETCH_ASSOC);
    foreach ($list as $k => $val) {
        $flagarr = explode(',',$val['no_flag']);
        $flag='';
        foreach ($flagarr as $key => $value) {
            if($value==1)$flag.='系统通知，';
            if($value==2)$flag.='手机短信通知，';
        }
        $flag = rtrim($flag,'，');
        $str_html.=' <tr>
                        <td>
                        <input type="checkbox" name="checkbox" lay-skin="primary" value="'.$val["id"].'"/>
                        </td>
                        <td>'.$val["id"].'</td>
                        <td>'.$val["truename"].'</td>
                        <td class="ellipsis">'.$val["content"].'</td>
                        <td>'.$val["s_success"].'</td>
                        <td>'.$val["s_fail"].'</td>
                        <td>'.$val["m_success"].'</td>
                        <td>'.$val["m_fail"].'</td> 
                        <td>'.$val["count"].'</td>
                        <td>'.$flag.'</td>
                        <td>'.$val["time"].'</td>
                        <td>    
                            <button class="layui-btn layui-btn-mini layui-btn-normal ajax"  data-opt="view"  data-id="'.$val["id"].'" data-type="'.$type.'">
                                <i class="iconfont">&#xe605;</i>查看
                            </button>
                            <button class="layui-btn layui-btn-mini layui-btn-danger ajax" data-opt="del"  data-id="'.$val["id"].'" data-type="'.$type.'">
                                <i class="iconfont">&#xe626;</i>删除
                            </button>
                        </td>
                    </tr>';

    }
    $rc=$T->db->query("select count(*) from sys_notice A where 1=1 ".$where)->fetchColumn(0);
}else{
    $where = "and locate('".$uid."',accepter)>0";
    $list = $T->db->query("select A.*,B.truename from sys_notice_list A left join sys_member B on B.id=A.sender where 1=1 ".$where." order by A.id desc limit {$offset},15");
    foreach ($list as $k => $val) {
        $str_html.=' <tr>
                        <td>
                        <input type="checkbox" name="checkbox" lay-skin="primary" value="'.$val["id"].'"/>
                        </td>
                        <td>'.$val["id"].'</td>
                        <td>'.$val["truename"].'</td>
                        <td class="ellipsis">'.$val["content"].'</td>
                        <td>'.$val["time"].'</td>
                        <td>    
                            <button class="layui-btn layui-btn-mini layui-btn-normal ajax"  data-opt="view"  data-id="'.$val["id"].'" data-type="'.$type.'">
                                <i class="iconfont">&#xe605;</i>查看
                            </button>
                            <button class="layui-btn layui-btn-mini layui-btn-danger ajax" data-opt="del"  data-id="'.$val["id"].'" data-type="'.$type.'">
                                <i class="iconfont">&#xe626;</i>删除
                            </button>
                        </td>
                    </tr>';
    }
    $rc=$T->db->query("select count(*) from sys_notice_list A where 1=1 ".$where)->fetchColumn(0);
}
if($p<1)$p=1;
$page=getPageHtml_bt($rc,15,$p,"&t=notice_sys&type=".$type);
$page=mb_convert_encoding($page, 'utf-8', 'utf-8');
$T->Set("page",$page);
$T->Set("type",$type);
$T->Set("str_html",$str_html);
          

$T->Set("template",$template);         
$T->clearNaN();       
$T->clearNoN();
$T->display(); 